<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>歌手管理</title>
    <link rel="icon" th:href="@{/source/favicon.ico}" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="歌手管理">
    <meta name="description" content="歌手管理">
    <meta name="author" content="lsy">
    <link th:href="@{/source/css/bootstrap.min.css}" href="/css/bootstrap.min.css" rel="stylesheet">
    <link th:href="@{/source/css/materialdesignicons.min.css}" href="/css/materialdesignicons.min.css" rel="stylesheet">
    <link th:href="@{/source/css/style.min.css}" href="/css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">

            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <a th:href="@{/index}" href="index.html"><img th:src="@{/source/img/logo-sidebar.png}"
                                                              src="images/logo-sidebar.png"
                                                              title="Kun" alt="Kun"/></a>
            </div>
            <div class="lyear-layout-sidebar-scroll">
                <nav class="sidebar-main">
                    <ul class="nav nav-drawer">

                        <li class="nav-item"><a th:href="@{/main}" href="index.html">
                            在线投票系统</a></li>
                        <li sec:authorize="hasRole('3')" class="nav-item"><a th:href="@{/singer}" href="index.html">
                            歌手报名信息</a></li>
                        <li sec:authorize="hasRole('2')" class="nav-item"><a th:href="@{/votepagejudge}"
                                                                             href="index.html">
                            评委投票</a></li>
                        <li sec:authorize="hasRole('1')"><a th:href="@{/battlecontrol}" href="lyear_pages_add_doc.html">PK控制</a></li>
                        <li sec:authorize="hasRole('0')" class="nav-item nav-item-has-subnav">
                            <a href="javascript:void(0)">用户管理</a>
                            <ul class="nav nav-subnav">
                                <li><a th:href="@{/user/doSingerList}" href="lyear_pages_gallery.html">歌手管理</a></li>
                                <li><a th:href="@{/user/doJudgeList}" href="lyear_pages_add_doc.html">评委管理</a></li>
                                <li><a th:href="@{/user/doStuffList}" href="lyear_pages_add_doc.html">工作人员管理</a>
                                </li>
                            </ul>
                        </li>

                        <li sec:authorize="hasRole('0')" class="nav-item nav-item-has-subnav">
                            <a href="javascript:void(0)">投票管理</a>
                            <ul class="nav nav-subnav">
                                <li><a th:href="@{/votepage}" href="lyear_pages_gallery.html">观众投票</a></li>
                                <li><a th:href="@{/votepagejudge}" href="lyear_pages_add_doc.html">评委投票</a></li>
                            </ul>
                        </li>

                        <li sec:authorize="hasRole('0')" class="nav-item nav-item-has-subnav">
                            <a href="javascript:void(0)">统计管理</a>
                            <ul class="nav nav-subnav">
                                <li><a th:href="@{/votescountlist}" href="lyear_pages_gallery.html">选手得票统计</a></li>
                            </ul>
                        </li>

                        <li sec:authorize="hasRole('0')" class="nav-item nav-item-has-subnav">
                            <a href="javascript:void(0)">赛制管理</a>
                            <ul class="nav nav-subnav">
                                <li><a th:href="@{/screen}" href="lyear_pages_gallery.html">屏幕管理</a></li>
                                <li><a th:href="@{/battlelist}" href="lyear_pages_add_doc.html">赛制设置</a></li>
                                <li><a th:href="@{/battlecontrol}" href="lyear_pages_add_doc.html">PK控制</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>

                <div class="sidebar-footer">

                </div>
            </div>

        </aside>
        <!--End 左侧导航-->

        <!--头部信息-->
        <header class="lyear-layout-header">

            <nav class="navbar navbar-default">
                <div class="topbar">

                    <div class="topbar-left">
                        <div class="lyear-aside-toggler">
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                            <span class="lyear-toggler-bar"></span>
                        </div>
                        <span class="navbar-page-title"> 系统中心 </span>
                    </div>
                </div>

                <h1><span sec:authorize="hasRole('0')">[管理员]</span>
                    <span sec:authorize="hasRole('1')">[工作人员]</span>
                    <span sec:authorize="hasRole('2')">[评委]</span>
                    <span sec:authentication="principal.username"></span>
                </h1>
                <a th:href="@{/user/logout}" href="#"> 退出登录</a>
            </nav>

        </header>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="table-responsive">
                                    <h1>未审核歌手列表</h1>
                                    <div class="btn-group">
                                        <a class="btn btn-xs btn-default"
                                           th:href="@{/unreviewed}"
                                           title="未审核歌手"
                                           data-toggle="tooltip">未审核歌手</a>
                                    </div>
                                    <div class="btn-group">
                                        <a class="btn btn-xs btn-default"
                                           th:href="@{/passed}"
                                           title="审核通过歌手"
                                           data-toggle="tooltip">审核通过歌手</a>
                                    </div>
                                    <div class="btn-group">
                                        <a class="btn btn-xs btn-default"
                                           th:href="@{/unsanctioned}"
                                           title="审核未通过歌手"
                                           data-toggle="tooltip">审核未通过歌手</a>
                                    </div>
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>歌手编号</th>
                                            <th>头像</th>
                                            <th>歌手名</th>
                                            <th>电话</th>
                                            <th>报名时间</th>
                                            <th>审核状态</th>
                                            <th>审核</th>
                                            <th>删除</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr th:each="users,item:${users}">
                                            <td th:text="${item.count}"></td>
                                            <td><img width="100px" id="photo" name="photo"
                                                     th:src="@{'/source/uploadfiles/'+ ${users.getPhoto()}}"
                                                     alt="图片审核中"
                                                     src=""></td>
                                            <td th:text="${users.getUsername()}"></td>
                                            <td th:text="${users.getPhone()}"></td>
                                            <td th:text="${#dates.format(users.getCreateTime,'yyyy-MM-dd')}"></td>
                                            <td th:text="${users.getStatus()} == '0' ? '免审人员' : (${users.getStatus()} == '1' ? '通过' : (${users.getStatus()} == '2' ? '不通过' : '待审'))"></td>
                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs btn-default"
                                                       th:href="@{/pass(userId=${users.getUserId()})}"
                                                       title="通过"
                                                       data-toggle="tooltip">通过</a>
                                                </div>

                                                <div class="btn-group">
                                                    <a class="btn btn-xs btn-default"
                                                       th:href="@{/fail(userId=${users.getUserId()})}"
                                                       title="不通过"
                                                       data-toggle="tooltip">不通过</a>
                                                </div>
                                            </td>
                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs btn-default"
                                                       th:href="@{/deleteSinger(userId=${users.getUserId()})}"
                                                       title="删除"
                                                       data-toggle="tooltip">删除</a>
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                    <ul class="pagination">
                                        <li class="page-item"><a class="page-link"
                                                                 href="/unreviewed?pageNum=1&pageSize=3">1</a>
                                        </li>
                                        <li class="page-item"><a class="page-link"
                                                                 href="/unreviewed?pageNum=2&pageSize=3">2</a>
                                        </li>
                                        <li class="page-item"><a class="page-link"
                                                                 href="/unreviewed?pageNum=3&pageSize=3">3</a>
                                        </li>
                                        <!-- Add more pages as needed -->

                                        <!-- 添加一个隐藏域，用于存储总记录数 -->
                                        <input type="hidden" id="totalCount" value="0"/>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<script type="text/javascript" th:src="@{/source/js/jquery.min.js}" src="js/jquery.min.js"></script>
<script type="text/javascript" th:src="@{/source/js/bootstrap.min.js}" src="js/bootstrap.min.js"></script>
<script type="text/javascript" th:src="@{/source/js/perfect-scrollbar.min.js}"
        src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" th:src="@{/source/js/main.min.js}" src="js/main.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('.search-bar .dropdown-menu a').click(function () {
            var field = $(this).data('field') || '';
            $('#search-field').val(field);
            $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
        });
    });
</script>
<script>
    $(function () {
        // 获取总记录数
        $.get("/user/getTotalCountUnreviewed", function (data) {
            $("#totalCount").val(data);
            generatePagination();
        });
    });

    function generatePagination() {
        // 计算总页数
        var pageSize = 3; // 每页显示的记录数
        var totalCount = parseInt($("#totalCount").val());
        var totalPages = Math.ceil(totalCount / pageSize);

        // 生成分页导航
        var html = "";
        for (var i = 1; i <= totalPages; i++) {
            html += '<li class="page-item"><a class="page-link" href="/unreviewed?pageNum=' + i + '&pageSize=' + pageSize + '">' + i + '</a></li>';
        }
        $(".pagination").html(html);
    }
</script>
</body>
</html>